from django.contrib import admin
from .models import Inspiration


@admin.register(Inspiration)
class InspirationAdmin(admin.ModelAdmin):
    """灵感库管理"""
    list_display = ['id', 'user', 'type', 'content_preview', 'tags', 'created_at']
    list_filter = ['type', 'created_at']
    search_fields = ['user__username', 'content', 'tags']
    readonly_fields = ['created_at']
    list_per_page = 20
    date_hierarchy = 'created_at'
    
    def content_preview(self, obj):
        """内容预览"""
        return obj.content[:50] + '...' if len(obj.content) > 50 else obj.content
    content_preview.short_description = '灵感内容'
